<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>编辑指南类别</title>
  <script type="text/javascript" src="assets/dwz/ui/uploadify/scripts/jquery.uploadify.js"></script>
  <script type="text/javascript">
    $(function(){
      //初始化uploadify 用于word上传
      $("#uploadFile").uploadify({
        'swf' : 'assets/dwz/ui/uploadify/scripts/uploadify.swf',//上传的flash文件,必用
        'uploader' : 'community_image_service',//上传的请求URL
        'method' : "get",//请求方式
        'fileObjName' : 'fileName',//与后台Action中file属性一样
        'formData' : {
          'uploadUrl' : 'hangzhou/talent'
        },//附带值，参数
        'auto' : true,//自动上传
        'multi' : false,//是否为多文件上传
        'buttonImage':'assets/dwz/ui/uploadify/img/upload.png',
        'uploadLimit' : 1111111,//一次可以上传多少个文件
        'fileSizeLimit' : '100000KB',//单个文件上传最大值
        'queueSizeLimit' : 100,//最多上传个数
        'successTimeout' : 99999,//上传超时时间
        'rollover' : true,
        'dataType':'text',
        'removeCompleted' : true,//上传完成后是否自动隐藏进度条
        onUploadSuccess : function(file,//每个文件上传完成后都会调用一次，其中data为，相应信息，file为上传文件信息,response只有两个值true or false
                                   data, response) {
            if( data == null ){
                alertErrorMessage("上传图片失败");
                return;
            }
            alertOkMessage( "上传成功！" );
            $(".edit_community_guide_form img").attr("src",data);
            $(".edit_community_guide_form input[name='imageUrl']").val(data);
        },
        onError : function() {
          alert("上传失败");
        }
      });
    })

    //错误提示
    function alertErrorMessage(word){
        alertMsg.error(word);
    }

    //成功提示
    function alertOkMessage(word){
        alertMsg.correct(word);
    }

    //删除图片
    $(".edit_community_guide_form .delete-this-pic").click(function () {
        $(".edit_community_guide_form img").attr("src","http://jielan.oss-cn-hangzhou.aliyuncs.com/qyh2%2Fimages%2Fapp_cover%2Fqy_yidongxiaoyuan.jpg");
        $(".edit_community_guide_form input[name='imageUrl']").val("");
    })
  </script>
</head>
  <body>
    <div class="page unitBox">
      <form method="post" action="save_edit_community_guide" class="pageForm required-validate edit_community_guide_form" onsubmit="return validateCallback(this, dialogAjaxDone)" novalidate="novalidate">
        <div class="pageContent">
          <div class="pageFormContent edit-guide-form" layouth="97">
            <dl>
              <dt>指南类别：</dt>
              <dd>
                <input type="text" class="required" name="guideName" value="${guide.guideName}" maxlength="20" placeholder="最多允许输入20个中文"/>
              </dd>
            </dl>
            <dl style="height: 110px;">
              <dt>图片logo：</dt>
              <dd style="position:relative;">
                <img src="${image.imageUrl}" width="120px;" height="80px;"/>
                <input type="file" name="file" id="uploadFile" />
                <input type="hidden" name="imageUrl" value="${image.imageUrl}"/>
                <a style="background: rgba(0,0,0,0.5);display:block;position:absolute;top:0;left:86px;padding:5px;text-align: center;color:#fff;" class="delete-this-pic">删除</a>
              </dd>
            </dl>
          </div>
          <input type="hidden" value="${guide.id}" name="id"/>
          <div class="formBar">
            <ul>
              <li>
                <div class="buttonActive">
                  <div class="buttonContent">
                    <button type="submit">保存</button>
                  </div>
                </div>
              </li>
              <li>
                <div class="button">
                  <div class="buttonContent">
                    <button class="close" type="button">关闭</button>
                  </div>
                </div>
              </li>
            </ul>
          </div>
        </div>
      </form>
    </div>
  </body>
</html>
